<script>
	import Vue from 'vue'
	import pageAnimation from './components/page-animation'
	export default {
		globalData: {
			debug: false,
			sceneId: '',
			openid: '',
			userid: '', //"Djo23Z56Ai86nB2KHbh"
			unitno: '', //A28
			version: 'Indonesia',
		},
		mixins: [pageAnimation],
		onLaunch: function() {
			// console.log(this.$constant.BASEURL)
			uni.getSystemInfo({
				success: function(e) {
					// #ifndef MP
					Vue.prototype.StatusBar = e.statusBarHeight;
					if (e.platform == 'android') {
						Vue.prototype.CustomBar = e.statusBarHeight + 50;
					} else {
						Vue.prototype.CustomBar = e.statusBarHeight + 45;
					};
					// #endif

					// #ifdef MP-WEIXIN
					Vue.prototype.StatusBar = e.statusBarHeight;
					let custom = wx.getMenuButtonBoundingClientRect();
					Vue.prototype.Custom = custom;
					Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
					// #endif		

					// #ifdef MP-ALIPAY
					Vue.prototype.StatusBar = e.statusBarHeight;
					Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
					// #endif
				}
			})
			if (this.globalData.version == this.$constant.PROJECT_YINNI) {
				if(!getApp().globalData.debug){
					let tmpUrlSearch = window.location.protocol+"//"+window.location.host+"/";
					// this.$constant.BASEURL = tmpUrlSearch
					console.log("protocol = ",window.location.protocol)
					console.log("host = ",window.location.host)
					console.log(this.$constant.BASEURL)
				}
				// console.log("tmpUrlSearch = " + tmpUrlSearch)
			} else {
				//获取用户授权
				let tmpUrlSearch = window.location.search; // 得到：?sceneid=h5&wxcode=xxx&puid=fff
				let tmpParas = GetRequestParameters(tmpUrlSearch);
				let tmpSceneID = tmpParas["code"]; //提取code参数, 用于获取openid

				console.log("tmpUrlSearch = " + tmpUrlSearch)
				console.log("tmpParas = " + tmpParas)
				console.log("tmpSceneID = " + tmpSceneID)

				if (tmpSceneID != null && typeof(tmpSceneID) != 'undefined') {
					// console.log("111111111")
					//将获取到的SceneID保存下来
					getApp().globalData.sceneId = tmpSceneID;
				} else {
					//重定向拿code
					if (getApp().globalData.debug) return;
					window.location.href = this.$constant.AUTHORIZE;
					return
				}
			}
		},
		onShow: function() {
			let isYunDianMao= this.$constant.BASEURL.indexOf("kq.lsyat.com")>-1
			if(!getApp().globalData.debug&&isYunDianMao){
				let tmpUrlSearch = window.location.protocol+"//"+window.location.host+"/";
				this.$constant.BASEURL = tmpUrlSearch
				console.log("protocol = ",window.location.protocol)
				console.log("host = ",window.location.host)
				console.log(this.$constant.BASEURL)
				
			}
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}

	export const GetRequestParameters = (locationsearch) => {
		let url = locationsearch;
		let theRequest = new Object();
		if (url.indexOf("?") != -1) {
			let str = url.substr(1);
			let strs = str.split("&");
			for (let i = 0; i < strs.length; i++) {
				theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
			}
		}
		return theRequest;
	}
</script>

<style>
	/*每个页面公共css */
	@import "components/colorui/main.css";
	@import "components/colorui/icon.css";

	.nav-list {
		display: flex;
		flex-wrap: wrap;
		padding: 0px 40upx 0px;
		justify-content: center;
	}

	.nav-li {
		padding: 30upx;
		border-radius: 12upx;
		width: 45%;
		margin: 0 2.5% 40upx;
		background-size: cover;
		background-position: center;
		position: relative;
		z-index: 1;
	}

	.nav-li::after {
		content: "";
		position: absolute;
		z-index: -1;
		background-color: inherit;
		width: 100%;
		height: 100%;
		left: 0;
		bottom: -10%;
		border-radius: 10upx;
		opacity: 0.2;
		transform: scale(0.9, 0.9);
	}

	.nav-li.cur {
		color: #fff;
		background: rgb(94, 185, 94);
		box-shadow: 4upx 4upx 6upx rgba(94, 185, 94, 0.4);
	}

	.nav-title {
		font-size: 32upx;
		font-weight: 300;
	}

	.nav-title::first-letter {
		font-size: 40upx;
		margin-right: 4upx;
	}

	.nav-name {
		font-size: 28upx;
		text-transform: Capitalize;
		margin-top: 20upx;
		position: relative;
	}

	.nav-name::before {
		content: "";
		position: absolute;
		display: block;
		width: 40upx;
		height: 6upx;
		background: #fff;
		bottom: 0;
		right: 0;
		opacity: 0.5;
	}

	.nav-name::after {
		content: "";
		position: absolute;
		display: block;
		width: 100upx;
		height: 1px;
		background: #fff;
		bottom: 0;
		right: 40upx;
		opacity: 0.3;
	}

	.nav-name::first-letter {
		font-weight: bold;
		font-size: 36upx;
		margin-right: 1px;
	}

	.nav-li text {
		position: absolute;
		right: 30upx;
		top: 30upx;
		font-size: 52upx;
		width: 60upx;
		height: 60upx;
		text-align: center;
		line-height: 60upx;
	}

	.text-light {
		font-weight: 300;
	}

	@keyframes show {
		0% {
			transform: translateY(-50px);
		}

		60% {
			transform: translateY(40upx);
		}

		100% {
			transform: translateY(0px);
		}
	}

	@-webkit-keyframes show {
		0% {
			transform: translateY(-50px);
		}

		60% {
			transform: translateY(40upx);
		}

		100% {
			transform: translateY(0px);
		}
	}
</style>
